<template>
    <div class="box">
        <div class="img">
            <img :src="$image+xiang.food_img" alt="">
            <p @click="back">
                 <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-zuojiantou"></use>
                </svg>
            </p>
        </div>
        <section>
            <p>{{xiang.name}}</p>
            <i>月售8</i>
             <div class="fen" @click="tian($event,xiang)">
                <p style="color:red;">￥<span style="font-size:15px">{{xiang.price}}</span>
                  <em style="color:gray">包装费 ￥{{xiang.bao_money}}/份</em>
                </p>
                <van-icon name="add" size="20px" color="#0000f8" />
            </div>
        </section>
        <section style="padding:2vw">
            <p style="font-size:14px">商品详情</p>
            <i><p style="width:17vw;font-size:11px;margin-top:.4vw">商品描述</p><p style="font-size:13px;color:black">{{xiang.jshao}}</p></i>
            <i style="margin-top:.6vw"><p style="width:14vw;font-size:11px;margin-top:.4vw">原料</p><p style="font-size:13px;color:black">{{xiang.details}}</p></i>
        </section>
       <footer>
           <Footer :Msg="msg"></Footer>
        </footer>
    </div>
</template>

<script>
import Footer from '../components/footerCar'
import {mapState} from 'vuex'
export default {
    name: '',
    data(){
        return{
           content:{},
           path:'',
           msg:[],
        }
    },
    methods:{
      back(){
        //   console.log(this.path)
          if(this.path=='/dianCan'){
              this.$router.push('/')
          }else if(this.path=='/tuiJian'){
             this.$router.push('/tuiJian');       
          }else if(this.path=='/search'){
              this.$router.push('/search')
          }
          
      },
      tian(e,item){
          console.log(e.target)
          if(e.target.tagName=="I"){
            this.msg.push(item)
          }
      }
    },
    components:{
       Footer,
    },
    computed:{
         ...mapState(['xiang','car'])
    },
    created(){
        this.msg=this.car;
        // console.log(this.$route.query.content)
        if(this.$route.params.data){
            this.$store.commit('setXiang',this.$route.params.data);
        }
       console.log(this.$route.params)
        // this.content=this.$route.params.data
        // console.log(this.content)
    },
    mounted(){
        //   console.log(this.xiang)
    },
   
    beforeRouteEnter (to, from, next) {
        // ...
        // console.log(to,from)
                next(vm=>{
                    vm.path=from.path;
                })
    },
    beforeMount(){

    }
}
</script>

<style scoped>
.box{
    height: 100vh;
    background-color: rgb(248, 244, 244);
}
img{
    width: 100%;
}
.img{
    position: relative;
    top: 0;
}
.img p{
    position: absolute;
    top: 2vw;
    left: 2vw;
    width: 8vw;
    height: 8vw;
    text-align: center;
    line-height: 9vw;
    border-radius: 50%;
    background-color: rgba(224, 221, 221,.5);
}
section{
    width: 92vw;
    margin: 2vw auto;
    border-radius: 10px;
    background-color: white;
    padding: 2vw;
    padding-bottom: 9vw;
    position: relative;
}
section>p{
    font-size: 15px;
    font-family: '黑体';
    margin: 1vw 0;
}
section>i{
    font-style: normal;
    color: gray;
    font-size: 10px;
    margin: .4vw;
    display: flex;
}
.fen{
   position: absolute;
    margin: 0vw 0;
   
    
    bottom: 2vw;
     display: flex;
      justify-content: space-between;
}
.fen>p{
    font-size: 12px;
    margin-right: 55vw;
}
footer{
    position: fixed;
    bottom: 0;
    z-index: 10000;
}
footer>div{
    width: 96vw;
    background-color: white;
    padding: 1.8vw 2vw;
    
}
footer button{
    position: absolute;
    right: 0;
    bottom: 0;
    width: 24vw;
    height: 100%;
    outline: none;
    border: none;
    background-color: chartreuse;
}
</style>